<html>
<head>
  <meta charset="utf-8">
  <title>Blockly Demo: Code</title>
  <script type="text/javascript" src="../blockly_compressed.js"></script>
  <script type="text/javascript" src="../../generators/arduino.js"></script>
  <script type="text/javascript" src="../../generators/arduino/control.js"></script>
  <script type="text/javascript" src="../../generators/arduino/logic.js"></script>
  <script type="text/javascript" src="../../generators/arduino/math.js"></script>
  <script type="text/javascript" src="../../generators/arduino/text.js"></script>
  <script type="text/javascript" src="../../generators/arduino/lists.js"></script>
  <script type="text/javascript" src="../../generators/arduino/variables.js"></script>
  <script type="text/javascript" src="../../generators/arduino/procedures.js"></script>
  <script type="text/javascript" src="../../language/en/_messages.js"></script>
  <script type="text/javascript" src="../../language/common/control.js"></script>
  <script type="text/javascript" src="../../language/common/logic.js"></script>
  <script type="text/javascript" src="../../language/common/math.js"></script>
  <script type="text/javascript" src="../../language/common/text.js"></script>
  <script type="text/javascript" src="../../language/common/lists.js"></script>
  <!--script type="text/javascript" src="../../language/common/variables.js"></script-->
  <script type="text/javascript" src="../../language/common/procedures.js"></script>
  <!-- define blocks -->
  <script type="text/javascript" src="../../generators/arduino/base.js"></script>
  <script type="text/javascript" src="../../generators/arduino/grove.js"></script>
  <!-- custom blocks -->
  <script type="text/javascript" src="../../generators/arduino/custom.js"></script>
  <script type="text/javascript" src="../../generators/arduino/irobot.js"></script>
  
  <style>
    html, body {
      background-color: #fff;
      margin: 0;
      padding:0;
      overflow: hidden;
    }
    .blocklySvg {
      height: 100%;
      width: 100%;
    }
  </style>
  <script>
    function init() {
      // Whitelist of blocks to keep.
      var newLanguage = {}
      var keepers = [
          //iRobot
          'irobot_sing',
          'irobot_move_straight', 'irobot_spin', 'irobot_curve',
          'irobot_set_motors',
          'irobot_cliff_sensor', 'irobot_bumper', 'irobot_wall_sensor',
          'irobot_cliff_signal',
          'irobot_variable_cliff_thresh',

          'irobot_halt',//actually grouped with control

          //io
          'inout_highlow',
          'inout_digital_write', 'inout_digital_read',
          'inout_analog_write', 'inout_analog_read',
          'serial_print', 'inout_buildin_led',

          //servo
          'servo_move', 'servo_read_degrees',
          //grove analog
          //'grove_rotary_angle', 'grove_temporature_sensor', 'grove_sound_sensor', 'grove_thumb_joystick',
          //grove
          //'grove_led', 'grove_button', 'grove_relay',
          //'grove_tilt_switch', 'grove_piezo_buzzer',
          //'grove_pir_motion_sensor', 'grove_line_finder',
          //'grove_rgb_led', 'grove_rgb_led_container', 'grove_rgb_led_item',
          //grove LCD
          //'grove_serial_lcd_print', 'grove_serial_lcd_power',
          //'grove_serial_lcd_effect', 'grove_ultrasonic_ranger',
          //grove motor
          //'grove_motor_shield',
          //grove bluetooth
          //'grove_bluetooth_slave',

          //control
          'base_delay', 
	  'controls_if', 
	  'controls_if_if', 
	  'controls_if_elseif', 
  	  'controls_if_else', 
  	  'controls_for',
	  'controls_forEach',
	  'controls_whileUntil', 
	  'controls_flow_statements',

          //math
          'base_map','math_number','math_arithmetic',//'math_modulo',

          //text
          'text', //'text_join','text_create_join_container','text_create_join_item',

          //logic
          'logic_compare', 'logic_operation', 'logic_negate', 'logic_null','logic_boolean',

          //variable
          'variables_get','variables_set', 'variables_declare',

          //procedure
          'procedures_defnoreturn', 'procedures_defreturn', 'procedures_callnoreturn', 'procedures_callreturn', 'procedures_mutatorcontainer', 'procedures_mutatorarg',
          'procedures_ifreturn',

          //custom
          //'custom_read','custom_write'
          ];
      for (var x = 0; x < keepers.length; x++) {
        newLanguage[keepers[x]] = Blockly.Language[keepers[x]];
      }
      // Fold control category into logic category.
      /*for (var name in newLanguage) {
        if (newLanguage[name].category == 'Math') {
          newLanguage[name].category = 'Logic';
        }
      }*/
      Blockly.Language = newLanguage;
      
      Blockly.inject(document.body, {path: '../../'});

      if (window.parent.init) {
        // Let the top-level application know that Blockly is ready.
        window.parent.init(Blockly);
      } else {
        // Attempt to diagnose the problem.
        var msg = 'Error: Unable to communicate between frames.\n\n';
        if (window.parent == window) {
          msg += 'Try loading index.html instead of frame.html';
        } else if (window.location.protocol == 'file:') {
          msg += 'This may be due to a security restriction preventing\n' +
              'access when using the file:// protocol.\n' +
              'http://code.google.com/p/chromium/issues/detail?id=47416';
        }
        alert(msg);
      }
    }
  </script>
</head>
<body onload="init()">
</body>
</html>
